load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "security",
    srcs = [
        "auth.go",
        "cert_expiry_cache.go",
        "cert_settings.go",
        "certificate_loader.go",
        "certificate_manager.go",
        "certificate_metrics.go",
        "certs.go",
        "join_token.go",
        "ocsp.go",
        "password.go",
        "pem.go",
        "permission_check.go",
        "tls.go",
        "tls_ciphersuites.go",
        "tls_settings.go",
        "utils.go",
        "x509.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/security",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb",
        "//pkg/security/certnames",
        "//pkg/security/distinguishedname",
        "//pkg/security/password",
        "//pkg/security/securityassets",
        "//pkg/security/username",
        "//pkg/server/telemetry",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/util/cache",
        "//pkg/util/encoding",
        "//pkg/util/envutil",
        "//pkg/util/log",
        "//pkg/util/log/eventpb",
        "//pkg/util/log/severity",
        "//pkg/util/metric",
        "//pkg/util/metric/aggmetric",
        "//pkg/util/mon",
        "//pkg/util/quotapool",
        "//pkg/util/randutil",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/sysutil",
        "//pkg/util/timeutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_errors//oserror",
        "@com_github_go_ldap_ldap_v3//:ldap",
        "@org_golang_x_crypto//bcrypt",
        "@org_golang_x_crypto//ocsp",
        "@org_golang_x_sync//errgroup",
    ],
)

go_test(
    name = "security_test",
    size = "medium",
    srcs = [
        "auth_test.go",
        "cert_expiry_cache_test.go",
        "certificate_loader_test.go",
        "certificate_manager_test.go",
        "certs_rotation_test.go",
        "certs_tenant_test.go",
        "certs_test.go",
        "join_token_test.go",
        "main_test.go",
        "permission_check_test.go",
        "tls_test.go",
        "x509_test.go",
    ],
    embed = [":security"],
    exec_properties = select({
        "//build/toolchains:is_heavy": {"test.Pool": "large"},
        "//conditions:default": {"test.Pool": "default"},
    }),
    deps = [
        "//pkg/base",
        "//pkg/multitenant/tenantcapabilities/tenantcapabilitiesauthorizer",
        "//pkg/roachpb",
        "//pkg/rpc",
        "//pkg/security/certnames",
        "//pkg/security/distinguishedname",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/security/username",
        "//pkg/server",
        "//pkg/settings/cluster",
        "//pkg/testutils",
        "//pkg/testutils/serverutils",
        "//pkg/util/envutil",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/metric/aggmetric",
        "//pkg/util/mon",
        "//pkg/util/randutil",
        "//pkg/util/stop",
        "//pkg/util/timeutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_go_ldap_ldap_v3//:ldap",
        "@com_github_stretchr_testify//require",
        "@org_golang_x_exp//rand",
    ] + select({
        "@io_bazel_rules_go//go/platform:aix": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:android": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:darwin": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:dragonfly": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:freebsd": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:illumos": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:ios": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:js": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:netbsd": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:openbsd": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:plan9": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "@io_bazel_rules_go//go/platform:solaris": [
            "//pkg/util/log/eventpb",
            "@com_github_prometheus_client_model//go",
            "@org_golang_x_sys//unix",
        ],
        "//conditions:default": [],
    }),
)
